package nix.spring.injection;

import nix.spring.domain.CollectionBean;
import nix.spring.domain.Person;

import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class Demo1 {

	@Test
	public void fun1() {

		ApplicationContext ac = new ClassPathXmlApplicationContext("nix/spring/injection/applicationContext.xml");
		Person p = (Person) ac.getBean("person");
		System.out.println(p);
	}
	
	@Test
	public void fun2() {

		ApplicationContext ac = new ClassPathXmlApplicationContext("nix/spring/injection/applicationContext.xml");
		Person p2 = (Person) ac.getBean("person2");
		Person p3 = (Person) ac.getBean("person3");
		Person p4 = (Person) ac.getBean("person4");
		System.out.println(p2);
		System.out.println(p3);
		System.out.println(p4);
	}
	
	@Test
	public void fun3() {

		ApplicationContext ac = new ClassPathXmlApplicationContext("nix/spring/injection/applicationContext.xml");
		Person p = (Person) ac.getBean("person5");
		System.out.println(p);
	}
	
	@Test
	public void fun4() {

		ApplicationContext ac = new ClassPathXmlApplicationContext("nix/spring/injection/applicationContext.xml");
		Person p = (Person) ac.getBean("person6");
		System.out.println(p);
	}
	
	@Test
	public void fun5() {

		ApplicationContext ac = new ClassPathXmlApplicationContext("nix/spring/injection/applicationContext.xml");
		CollectionBean cb = (CollectionBean) ac.getBean("cb");
		System.out.println(cb);
	}
}
